package fr.pascal.client.ui.selection;

import com.google.gwt.activity.shared.AbstractActivity;
import com.google.gwt.event.shared.EventBus;
import com.google.gwt.user.client.ui.AcceptsOneWidget;

import fr.pascal.client.ClientFactory;
import fr.pascal.client.mvp.MainPlace;

public class SelectionRubriquesActivity extends AbstractActivity implements SelectionRubriques.Presenter {

	private ClientFactory clientFactory; 
	private String selectedRubrique;

	public SelectionRubriquesActivity(MainPlace place, ClientFactory clientFactory) {
		this.clientFactory = clientFactory;
		// affectation donnees metier
		selectedRubrique = place.getToken();
	}

	@Override
	public void start(AcceptsOneWidget panel, EventBus eventBus) {
		SelectionRubriques selectionRubriquesView = clientFactory.getSelectionRubriquesView();
		selectionRubriquesView.setPresenter(this);
		// affectation donnees metier
		selectionRubriquesView.setSelectedRubrique(selectedRubrique);
		panel.setWidget(selectionRubriquesView.asWidget());
	}

	@Override
	public void goTo(String rubrique) {
		MainPlace mainPlace = new MainPlace(rubrique);
		clientFactory.getPlaceController().goTo(mainPlace);
	}
}
